
import {  useCameraPermission,useMicrophonePermission } from 'react-native-vision-camera';

export const useAllPermissions = () => {
    const cameraPerm = useCameraPermission();
  const micPerm = useMicrophonePermission();
  const {hasPermission: hasCameraPermission, requestPermission: requestCamera} = useCameraPermission()

  const { hasPermission:hasMicrophonePermission, requestPermission: requestMicrophone } = useMicrophonePermission()

  const requestAllPermissions = async () => {
     if (!hasCameraPermission) {
          await requestCamera()
        }
        if(!hasMicrophonePermission) {
           await requestMicrophone()
        }
  };

  const hasCameraPermissions = () => cameraPerm.hasPermission;
const hasVoicePermissions = () => micPerm.hasPermission;

  return {
    hasCameraPermission: cameraPerm.hasPermission,
    hasMicrophonePermission: micPerm.hasPermission,
    requestAllPermissions,
    hasCameraPermissions,
    hasVoicePermissions
  };
};